<tagLib name="html" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>权限增加</TITLE>
<html:link type="js" href ="../Public/Js/Common.js" />
<html:link type="js" href ="../Public/Js/DateTimeCalendar.js" />
<html:import type="js" file="Js.Base" /> 
<html:import type="js" file="Js.prototype" /> 
<html:import type="js" file="Js.mootools" /> 
<html:import type="js" file="Js.Ajax.ThinkAjax" /> 
<html:import type="js" file="Js.Form.CheckForm" /> 
<html:import type="js" file="Js.Util.ImageLoader" /> 

<html:link type="css" href ="../Public/css/style.css" />
<SCRIPT LANGUAGE="JavaScript">
<!--
function ok(){
	var result = new Array();
	var obj	   = form1.group.options;
	var j=0;
	for(var i=0;i<obj.length;i++){
		if (obj[i].selected==true){
			result[j] = new Array();
			result[j][0]	=	obj[i].text;
			result[j][1]	=	obj[i].value;
			j++;
		}
	}
	returnValue=result;
	window.close(); 
}
	//JS装载专业
	function completeYx(data,status){
		if (status==1)
		{
			var StrObj=$('DM_Yx');
			StrObj.length = 0;
			StrObj.options[StrObj.length] = new Option("==请选择==", "");
			for(var i=0;i<data.length;i++){
				var d=data[i];
				StrObj.options[StrObj.length] = new Option(d.text, d.value);
			}
		}
	}
	//触发专业方法	
	function selectYx(){
		ThinkAjax.sendForm('form1','__URL__/selectYx/',completeYx,'result');
	}
	//JS装载专业
	function completeZy(data,status){
		if (status==1)
		{
			var StrObj=$('DM_ZY');
			StrObj.length = 0;
			StrObj.options[StrObj.length] = new Option("==请选择==", "");
			for(var i=0;i<data.length;i++){
				var d=data[i];
				StrObj.options[StrObj.length] = new Option(d.text, d.value);
			}
		}
	}
	//触发专业方法	
	function selectZy(yx){
		if(yx)	ThinkAjax.sendForm('form1','__URL__/selectZy/yx/'+yx,completeZy,'result');
	}
	
	
	
	//JS装载班级
	function completeBj(data,status){
		if (status==1)
		{
			var StrObj=$('DM_BJ');
			StrObj.length = 0;
			StrObj.options[StrObj.length] = new Option("==请选择==", "");
			for(var i=0;i<data.length;i++){
				var d=data[i];
				StrObj.options[StrObj.length] = new Option(d.text, d.value);
			}
		}
	}
	//触发班级方法	
	function selectBj(zy){
		if(zy)	ThinkAjax.sendForm('form1','__URL__/selectBj/zy/'+zy,completeBj,'result');
	}
	//JS装载班级
	function completeCheckSameBj(data,status){
		if (status==1)
		{
			if(data) alert(data);
		}
	}
	//触发班级方法	
	function checkSameBj(bj){
		if(bj)	ThinkAjax.sendForm('form1','__URL__/checkSameBj/DM_BJ/'+bj,completeCheckSameBj,'result');
	}	
	//出现触发,显示
	function displaySelect(){
		var role=$('ROLE_ID').value;
		//当角色为6时候可以显示
		if(role==6){
			$('DM_YX').disabled=false;
			$('DM_ZY').disabled=false;
			$('DM_BJ').disabled=false;
		}else if(role==1){
			$('DM_YX').disabled=true;
			$('DM_YX').value="";			
			$('DM_BJ').disabled=true;
			$('DM_BJ').value="";		
			$('DM_ZY').disabled=true;
			$('DM_ZY').value="";			
			$('DM_BJ').disabled=true;
			$('DM_BJ').value="";									
		}else{
			$('DM_YX').disabled=false;
			$('DM_YX').value="";		
			$('DM_ZY').disabled=true;
			$('DM_ZY').value="";			
			$('DM_BJ').disabled=true;
			$('DM_BJ').value="";			
		}
	}
	
//-->
</SCRIPT>
<base target="_self" />
</HEAD>

<BODY style="margin:0;overflow:hidden">
<FORM METHOD="POST" style="margin:0" name = "form1" ACTION="">
<div align="center">
<TABLE cellpadding=3 cellspacing=3 align="left">

<TR>
  <TD class="tRight">用户组：</TD>
  <TD class="tLeft"><SELECT class="bLeft"  NAME="ROLE_ID" id="ROLE_ID" onChange="displaySelect();">
  	<iterate name="rolelist" id="v">
    <option value="{$v.id}">{$v.name}</option>
	</iterate>
	</SELECT></TD>
</TR>
<TR>
  <TD class="tRight" >院系：</TD>
  <TD class="tLeft" ><SELECT class="bLeft"  NAME="DM_YX" id="DM_YX" onChange="selectZy(this.value);if(this.value)$('YX').value=this.options[this.selectedIndex].text;else $('YX').value='';">
  	<option value="">==请选择==</option>
  	<iterate name="yxlist" id="v">
    <option value="{$v.CODE}" <eq name="vo.DM_YX" value="$v['CODE']" >selected</eq>>{$v.CODENAME}</option>
	</iterate>
	</SELECT><INPUT TYPE="hidden"  NAME="YX" id="YX" value="{$vo.YX}"></TD>
</TR>
<TR>
  <TD class="tRight" >专业：</TD>
  <TD class="tLeft" ><SELECT class="bLeft"  NAME="DM_ZY" id="DM_ZY" onChange="selectBj(this.value);if(this.value)$('ZY').value=this.options[this.selectedIndex].text;else $('ZY').value='';">
  	<option value="">==请选择==</option>
  	<iterate name="zylist" id="v">
    <option value="{$v.CODE}" <eq name="vo.DM_ZY" value="$v['CODE']" >selected</eq>>{$v.CODENAME}</option>
	</iterate>
	</SELECT><INPUT TYPE="hidden"  NAME="ZY" id="ZY" value="{$vo.ZY}" ></TD>
</TR>
<TR>
  <TD class="tRight" >班级：</TD>
  <TD class="tLeft" ><SELECT class="bLeft"  NAME="DM_BJ" id="DM_BJ" onChange="if(this.value)$('BJ').value=this.options[this.selectedIndex].text;else $('BJ').value='';checkSameBj(this.value);">
  	<option value="">==请选择==</option>
  	<iterate name="bjlist" id="v">
    <option value="{$v.CODE}" <eq name="vo.DM_BJ" value="$v['CODE']" >selected</eq>>{$v.CODENAME}</option>
	</iterate>
	</SELECT><INPUT TYPE="hidden"  NAME="BJ" id="BJ" value="{$vo.BJ}" ></TD>
</TR>

<TR>
	<TD ></TD>
	<TD class="center">
	<INPUT TYPE="hidden" name="ajax" value="1">
	<INPUT TYPE="hidden" name="USER_ID" value="<?php echo $_GET['USER_ID'];?>">	
	<INPUT TYPE="button" value="保 存" onClick="sendForm('form1','__URL__/insertRight/');returnValue='ok';setTimeout('window.close()',1000);" class="small submit">
	<INPUT TYPE="reset" class="submit  small" value="清 空" >	</TD>
</TR>
</TABLE>
</div>
</FORM>
<script>selectYx();displaySelect();</script>
</html>